﻿using System;
using System.Windows;
using System.Windows.Controls;
using Samurai.WorkflowGraph.Models;

namespace Samurai.WorkflowGraph.Selectors
{
    public class ShapeTemplateSelector : DataTemplateSelector
    {
        public DataTemplate WorkflowStartNodeTemplate { get; set; }

        public DataTemplate DelegatedStepNodeTemplate { get; set; }

        public DataTemplate ClassStepNodeTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item == null) throw new ArgumentNullException("item");

            if (item is StartWorkflowNode)
                return WorkflowStartNodeTemplate;

            if (item is WorkflowStepNode && ((WorkflowStepNode)item).IsDelegatedStep)
                return DelegatedStepNodeTemplate;

            return null;
        }
    }
}
